﻿using System.Globalization;
using System.Windows.Data;

namespace Chaotic.Module.DBTool.Converters
{
    [ValueConversion(typeof(bool), typeof(string))]
    public class IsNullConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(bool)value)
            {
                return "not null";
            }
            return "null";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string text = value.ToString();
            if (text == "null")
            {
                return true;
            }
            return false;
        }
    }
}
